﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tradex {

    /// <summary>
    /// The FeedKey is used to identify a unique data feed (system). As different connectors and end points
    /// may deliver slightly varying market data, the FeedKey can be used to identify a specific system whenever
    /// market data is requested.
    /// </summary>
    [Serializable ()]
    public sealed class FeedKey {

        /// <summary>
        /// Constructor taking the key value.
        /// </summary>
        /// <param name="feed"></param>
        public FeedKey(string feed) {
            Feed = feed;
        }

        /// <summary>
        /// Gets the feed code.
        /// </summary>
        public string Feed { get; private set; }

        /// <inheritdoc />
        public override int GetHashCode() {
            return base.GetHashCode();
        }

        /// <inheritdoc />
        public override bool Equals(object obj) {
            FeedKey kObj = obj as FeedKey;
            if (kObj == null) {
                return false;
            }
            return kObj == this;
        }

        /// <inheritdoc />
        public static bool operator ==(FeedKey left, FeedKey right) {
            if (Object.ReferenceEquals(left, right)) {
                return true;
            }
            if (Object.ReferenceEquals(right, null)) {
                return false;
            }
            if (Object.ReferenceEquals(left, null)) {
                return false;
            }
            if (left.Feed != right.Feed) {
                return false;
            }
            return true;
        }

        /// <inheritdoc />
        public static bool operator !=(FeedKey left, FeedKey right) {
            if (Object.ReferenceEquals(left, right)) {
                return true;
            }
            if (Object.ReferenceEquals(right, null)) {
                return false;
            }
            if (Object.ReferenceEquals(left, null)) {
                return false;
            }
            if (left.Feed != right.Feed) {
                return true;
            }
            return false;
        }


    }

}
